import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'

// require.context() 是用来加载指定目录下的文件(模块)
// 语法：require.context('指定的目录的路径','Boolean是否递归获取','正则规则匹配指定的文件')
// const req = require.context('./modules', false, /\.js$/)
// const mdName = req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0]) // ['app', 'settings', 'user']
// const mdM = req.keys().map(item => req(item)) // [Module, Module, Module] Module.default

// const obj = {}

// mdName.forEach((item, index) => {
//   obj[item] = mdM[index].default
// })

// console.log(obj, 'obj')

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: { app, settings, user },
  getters
})

export default store
